package cn.kickegg.concurrent.collections.queue.demo;

import java.util.concurrent.BlockingQueue;

public class Producer implements Runnable {

    private BlockingQueue<Message> queue;

    public Producer(BlockingQueue<Message> q){
        this.queue=q;
    }
    @Override
    public void run() {
        for(;;){
            Message msg = new Message(""+1);
            try {
                queue.put(msg);
                System.out.println("生产："+msg.getMsg());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }

}